/** * Copyright (c) 2016-2019 人人开源 All rights reserved. */

package com.joinval.modules.sys.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.joinval.common.utils.Constant;
import com.joinval.common.utils.MapUtils;
import com.joinval.modules.sys.dao.SysMenuDao;
import com.joinval.modules.sys.entity.SysMenuEntity;
import com.joinval.modules.sys.service.SysMenuService;
import com.joinval.modules.sys.service.SysRoleMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("sysMenuService")
public class SysMenuServiceImpl extends ServiceImpl<SysMenuDao, SysMenuEntity> implements SysMenuService {


	@Autowired
	private SysRoleMenuService sysRoleMenuService;


	@Override
	public List<SysMenuEntity> queryListParentId(Long parentId) {
		return baseMapper.queryListParentId(parentId);
	}

	@Override
	public List<SysMenuEntity> myMenu(Long userId) {
		if(userId == Constant.SUPER_ADMIN){
			return baseMapper.myMenu(null);
		}
		return baseMapper.myMenu(userId);
	}

	@Override
	public void delete(Long menuId){
		//删除菜单
		this.removeById(menuId);
		//删除菜单与角色关联
		sysRoleMenuService.removeByMap(new MapUtils().put("menu_id", menuId));
	}


}
